package com.resource.noticemanage.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.resource.common.utils.PageUtils;
import com.resource.common.utils.R;
import com.resource.homeworkmanage.entity.TMessageNoticeEntity;
import com.resource.noticemanage.service.TMessageNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 消息通知表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-04-04 09:53:34
 */
@RestController
@RequestMapping("notice/tmessagenotice")
public class TMessageNoticeController{
    @Autowired
    private TMessageNoticeService tMessageNoticeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tMessageNoticeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		TMessageNoticeEntity tMessageNotice = tMessageNoticeService.getById(id);

        return R.ok().put("tMessageNotice", tMessageNotice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TMessageNoticeEntity tMessageNotice){
		tMessageNoticeService.save(tMessageNotice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TMessageNoticeEntity tMessageNotice){
        tMessageNotice.setCheckResult("已处理");
		tMessageNoticeService.updateById(tMessageNotice);
        return R.ok();
    }
    /**
     * 提交反馈
     */
    @RequestMapping("/dealwith")
    public R dealwith(@RequestBody List<TMessageNoticeEntity> tMessageNotice){
        return tMessageNoticeService.dealMessageBatch(tMessageNotice);
    }



    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		tMessageNoticeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    //提交考试接口
    @RequestMapping(value="/submitExam",method= RequestMethod.POST)
    public boolean submitNoticeByExam(@RequestParam Map<String, Object> map){
        return tMessageNoticeService.submitNoticeByExam(map);
    };

    //提交作业接口
    @RequestMapping(value="/submitHomework",method= RequestMethod.POST)
    public boolean submitNoticeByHomework(@RequestParam Map<String, String> map){
        return tMessageNoticeService.submitNoticeByHomework(map);
    };

}
